home *** CD-ROM | disk | FTP | other *** search
- head 1.7;
- branch ;
- access ;
- symbols sprited:1.6.1;
- locks ; strict;
- comment @ * @;
-
-
- 1.7
- date 92.07.10.14.57.28; author kupfer; state Exp;
- branches ;
- next 1.6;
-
- 1.6
- date 92.07.09.18.26.10; author jhh; state Exp;
- branches 1.6.1.1;
- next 1.5;
-
- 1.5
- date 90.08.29.17.18.31; author ouster; state Exp;
- branches ;
- next 1.4;
-
- 1.4
- date 90.08.29.17.02.17; author mgbaker; state Exp;
- branches ;
- next 1.3;
-
- 1.3
- date 89.08.15.21.11.45; author jhh; state Exp;
- branches ;
- next 1.2;
-
- 1.2
- date 88.11.11.14.11.19; author brent; state Exp;
- branches ;
- next 1.1;
-
- 1.1
- date 88.10.31.14.28.23; author brent; state Exp;
- branches ;
- next ;
-
- 1.6.1.1
- date 92.07.10.15.43.15; author kupfer; state Exp;
- branches ;
- next ;
-
-
- desc
- @Tool to turn on/off the RPC system, and to toggle debug/tracing switches
- inthe RPC system.
- @
-
-
- 1.7
- log
- @Fixed includes (<> instead of ""). Added -Creset and -Sreset options.
- Fixed call to Opt_Parse. Lint.
- @
- text
- @/*
- * rpccmd.c --
- *
- * User interface to RPC related commands of the Fs_Command system call.
- *
- * Copyright (C) 1986 Regents of the University of California
- * All rights reserved.
- * Permission to use, copy, modify, and distribute this
- * software and its documentation for any purpose and without
- * fee is hereby granted, provided that the above copyright
- * notice appear in all copies. The University of California
- * makes no representations about the suitability of this
- * software for any purpose. It is provided "as is" without
- * express or implied warranty.
- */
-
- #ifndef lint
- static char rcsid[] = "$Header: /sprite/src/cmds/rpccmd/RCS/rpccmd.c,v 1.6 92/07/09 18:26:10 jhh Exp Locker: kupfer $ SPRITE (Berkeley)";
- #endif not lint
-
- #include <sprite.h>
- #include <status.h>
- #include <option.h>
- #include <stdio.h>
- #include <fs.h>
- #include <fsCmd.h>
- #include <sysStats.h>
- #include <rpc.h>
- #include <host.h>
-
- /*
- * Command line options.
- */
-
- int rpcEnable = -1;
- int rpcDebug = -1;
- int rpcTracing = -1;
- int rpc_NoTimeouts = -1;
- int rpcClientHist = -1;
- int rpcServerHist = -1;
- Boolean resetClientHist = FALSE;
- Boolean resetServerHist = FALSE;
- char *rpcEchoHost = (char *)0;
- int blockSize = 32;
- int rpcMaxServers = -1;
- int rpcNumServers = -1;
- int rpcNegAcks = -1;
- int rpcChannelNegAcks = -1;
- int rpcNumNackBufs = -1;
- int numEchoes = 100;
- int sanityChecks = -1;
-
- Option optionArray[] = {
- {OPT_TRUE, "on", (Address) &rpcEnable,
- "\tAllow servicing of RPC requests."},
- {OPT_FALSE, "off", (Address) &rpcEnable,
- "\tTurn off servicing of RPC requests."},
- {OPT_STRING, "ping", (Address) &rpcEchoHost,
- "\tRPC test against the specified host."},
- {OPT_INT, "b", (Address) &blockSize,
- "\tBlock size to send in RPC test."},
- {OPT_INT, "t", (Address) &rpcTracing,
- "\tSet rpc tracing flag."},
- {OPT_INT, "T", (Address) &rpc_NoTimeouts,
- "\tSet rpc no timeouts flag."},
- {OPT_INT, "D", (Address) &rpcDebug,
- "\tSet rpc debug flag."},
- {OPT_INT, "C", (Address) &rpcClientHist,
- "\tSet client histogram flag."},
- {OPT_INT, "S", (Address) &rpcServerHist,
- "\tSet server histogram flag."},
- {OPT_TRUE, "Creset", (Address) &resetClientHist,
- "\tReset client RPC histograms."},
- {OPT_TRUE, "Sreset", (Address) &resetServerHist,
- "\tReset server RPC histograms."},
- {OPT_INT, "maxServers", (Address) &rpcMaxServers,
- "\tSet the maximum number of allowed rpc server processes."},
- {OPT_INT, "numServers", (Address) &rpcNumServers,
- "\tCreate more rpc servers until this number exists."},
- {OPT_TRUE, "negAcksOn", (Address) &rpcNegAcks,
- "\tTurn on negative acknowledgements on a server."},
- {OPT_FALSE, "negAcksOff", (Address) &rpcNegAcks,
- "\tTurn off negative acknowledgements on a server (default)."},
- {OPT_INT, "numNackBufs", (Address) &rpcNumNackBufs,
- "\tMake sure this number of negative ack buffers exists."},
- {OPT_TRUE, "channelNegAcksOn", (Address) &rpcChannelNegAcks,
- "\tSet the client policy for handling negative acks to ramp down number of channels."},
- {OPT_FALSE, "channelNegAcksOff", (Address) &rpcChannelNegAcks,
- "\tSet the client policy for handling negative acks to the default backoff policy."},
- {OPT_INT, "numPings", (Address) &numEchoes,
- "\tNumber of pings to send."},
- {OPT_INT, "sanity", (Address)&sanityChecks,
- "\tTurn off/on rpc sanity checks."},
-
- };
- int numOptions = sizeof(optionArray) / sizeof(Option);
-
- /* forward references: */
-
- static void ResetClientHist();
- static void ResetServerHist();
- ReturnStatus SetFlag();
-
-
- /*
- *----------------------------------------------------------------------
- *
- * main --
- *
- * Collects arguments and branch to the code for the fs command.
- *
- * Results:
- * None.
- *
- * Side effects:
- * Calls Fs_Command...
- *
- *----------------------------------------------------------------------
- */
- main(argc, argv)
- int argc;
- char *argv[];
- {
- register ReturnStatus status = SUCCESS; /* status of system calls */
-
- argc = Opt_Parse(argc, argv, optionArray, numOptions, 0);
-
- /*
- * Set various rpc system flags. The Fs_Command system call returns
- * the old value of the flag in place of the value passed in.
- */
- if (rpcEnable != -1) {
- status = Sys_Stats(SYS_RPC_ENABLE_SERVICE, rpcEnable, NIL);
- }
- if (rpcTracing != -1) {
- status = SetFlag(FS_SET_RPC_TRACING, rpcTracing, "RPC tracing");
- }
- if (rpc_NoTimeouts != -1) {
- status = SetFlag(FS_SET_RPC_NO_TIMEOUTS, rpc_NoTimeouts,
- "No RPC timeouts");
- }
- if (rpcDebug != -1) {
- status = SetFlag(FS_SET_RPC_DEBUG, rpcDebug, "RPC debug prints");
- }
- if (rpcClientHist != -1) {
- status = SetFlag(FS_SET_RPC_CLIENT_HIST, rpcClientHist,
- "Client RPC timing histograms");
- }
- if (rpcServerHist != -1) {
- status = SetFlag(FS_SET_RPC_SERVER_HIST, rpcServerHist,
- "Server RPC timing histograms");
- }
- if (resetClientHist) {
- ResetClientHist();
- }
- if (resetServerHist) {
- ResetServerHist();
- }
- if (rpcMaxServers != -1) {
- status = Sys_Stats(SYS_RPC_SET_MAX, rpcMaxServers, NIL);
- }
- if (rpcNumServers != -1) {
- status = Sys_Stats(SYS_RPC_SET_NUM, rpcNumServers, NIL);
- }
- if (rpcNegAcks != -1) {
- status = Sys_Stats(SYS_RPC_NEG_ACKS, rpcNegAcks, NIL);
- }
- if (rpcNumNackBufs != -1) {
- status = Sys_Stats(SYS_RPC_NUM_NACK_BUFS, rpcNumNackBufs, NIL);
- }
- if (rpcChannelNegAcks != -1) {
- status = Sys_Stats(SYS_RPC_CHANNEL_NEG_ACKS, rpcChannelNegAcks, NIL);
- }
- if (rpcEchoHost != (char *)0) {
- status = RpcEcho(rpcEchoHost);
- }
- if (sanityChecks != -1) {
- status = Sys_Stats(SYS_RPC_SANITY_CHECK, sanityChecks, NIL);
- }
- exit(status);
- }
-
- RpcEcho(server)
- char *server;
- {
- Host_Entry *entryPtr;
- int serverID;
- int myID;
- int error;
- char buffer[16 * 1024];
- Time deltaTime;
-
- entryPtr = Host_ByName(server);
- if (entryPtr == (Host_Entry *) NULL) {
- fprintf(stderr, "Unable to get host number for host '%s'\n",
- server);
- exit(1);
- }
- serverID = entryPtr->id;
-
- error = Proc_GetHostIDs((int *) NULL, &myID);
- if (error != SUCCESS) {
- perror( "Proc_GetHostIDs");
- exit(error);
- }
- if (myID == serverID) {
- fprintf(stderr, "Unable to send RPC to yourself.\n");
- exit(1);
- }
- error = DoTest(TEST_RPC_SEND, serverID, numEchoes, blockSize, buffer,
- buffer, &deltaTime);
- if (error != SUCCESS) {
- Stat_PrintMsg(error, "RPC failed:");
- } else {
- printf("Send %d bytes %d.%06d sec\n", blockSize, deltaTime.seconds,
- deltaTime.microseconds);
- }
- return(error);
- }
- ReturnStatus
- DoTest(command, serverID, numEchoes, size, inDataBuffer, outDataBuffer, timePtr)
- int command;
- int serverID;
- int numEchoes;
- int size;
- Address inDataBuffer;
- Address outDataBuffer;
- Time *timePtr;
- {
- Rpc_EchoArgs echoArgs;
- ReturnStatus error;
-
- echoArgs.serverID = serverID;
- echoArgs.n = numEchoes;
- echoArgs.size = size;
- echoArgs.inDataPtr = inDataBuffer;
- echoArgs.outDataPtr = outDataBuffer;
- echoArgs.deltaTimePtr = timePtr;
- error = Test_Rpc(command, &echoArgs);
-
- return(error);
- }
-
- ReturnStatus
- SetFlag(command, value, comment)
- int command; /* Argument to Fs_Command */
- int value; /* Value for flag */
- char *comment; /* For Io_Print */
- {
- register int newValue;
- register ReturnStatus status;
-
- newValue = value;
- status = Fs_Command(command, sizeof(int), (Address) &value);
- printf("%s %s, was %s\n", comment,
- newValue ? "on" : "off",
- value ? "on" : "off");
- return(status);
- }
-
-
- /*
- *----------------------------------------------------------------------
- *
- * ResetClientHist --
- *
- * Reset the client-side histograms.
- *
- * Results:
- * None.
- *
- * Side effects:
- * None.
- *
- *----------------------------------------------------------------------
- */
-
- static void
- ResetClientHist()
- {
- ReturnStatus status;
-
- status = Sys_Stats(SYS_RPC_CLIENT_HIST, 0, NULL);
- if (status != SUCCESS) {
- fprintf(stderr, "Can't reset client RPC histograms: %s\n",
- Stat_GetMsg(status));
- }
- }
-
-
- /*
- *----------------------------------------------------------------------
- *
- * ResetServerHist --
- *
- * Reset the server-side histograms.
- *
- * Results:
- * None.
- *
- * Side effects:
- * None.
- *
- *----------------------------------------------------------------------
- */
-
- static void
- ResetServerHist()
- {
- ReturnStatus status;
-
- status = Sys_Stats(SYS_RPC_SERVER_HIST, 0, NULL);
- if (status != SUCCESS) {
- fprintf(stderr, "Can't reset server RPC histograms: %s\n",
- Stat_GetMsg(status));
- }
- }
- @
-
-
- 1.6
- log
- @Add -sanity option. (Mike checking in for John.)
- @
- text
- @d18 1
- a18 1
- static char rcsid[] = "$Header: /sprite/src/cmds/rpccmd/RCS/rpccmd.c,v 1.5 90/08/29 17:18:31 ouster Exp Locker: jhh $ SPRITE (Berkeley)";
- d21 9
- a29 9
- #include "sprite.h"
- #include "status.h"
- #include "option.h"
- #include "stdio.h"
- #include "fs.h"
- #include "fsCmd.h"
- #include "sysStats.h"
- #include "rpc.h"
- #include "host.h"
- d41 2
- d72 4
- d98 6
- d126 1
- a126 1
- argc = Opt_Parse(argc, argv, optionArray, numOptions);
- d153 6
- a244 15
- SetInt(command, value, comment)
- int command; /* Argument to Fs_Command */
- int value; /* Value for int */
- char *comment; /* For Io_Print */
- {
- register int newValue;
- register ReturnStatus status;
-
- newValue = value;
- status = Fs_Command(command, sizeof(int), (Address) &value);
- printf("%s %d, was %d\n", comment, newValue, value);
- return(status);
- }
-
- ReturnStatus
- d259 58
- @
-
-
- 1.6.1.1
- log
- @Initial branch for Sprite server.
- @
- text
- @d18 1
- a18 1
- static char rcsid[] = "$Header: /sprite/src/cmds/rpccmd/RCS/rpccmd.c,v 1.6 92/07/09 18:26:10 jhh Exp $ SPRITE (Berkeley)";
- @
-
-
- 1.5
- log
- @Added "numPings" option.
- @
- text
- @d18 1
- a18 1
- static char rcsid[] = "$Header: /sprite/src/cmds/rpccmd/RCS/rpccmd.c,v 1.3 89/08/15 21:11:45 jhh Exp Locker: mgbaker $ SPRITE (Berkeley)";
- d49 1
- d86 3
- a88 1
-
- d158 3
- @
-
-
- 1.4
- log
- @Added many more options.
- @
- text
- @d48 1
- d83 2
- d186 2
- a187 2
- error = DoTest(TEST_RPC_SEND, serverID, 100, blockSize, buffer, buffer,
- &deltaTime);
- @
-
-
- 1.3
- log
- @changed call to Sys_GetMachineInfo to Proc_GetHostIDs
- @
- text
- @d18 1
- a18 1
- static char rcsid[] = "$Header: /a/newcmds/rpccmd/RCS/rpccmd.c,v 1.2 88/11/11 14:11:19 brent Exp Locker: jhh $ SPRITE (Berkeley)";
- d43 5
- d68 15
- d134 15
- @
-
-
- 1.2
- log
- @Added -ping option
- @
- text
- @d18 1
- a18 1
- static char rcsid[] = "$Header: /a/newcmds/rpccmd/RCS/rpccmd.c,v 1.1 88/10/31 14:28:23 brent Exp $ SPRITE (Berkeley)";
- d139 1
- a139 1
- error = Sys_GetMachineInfo((int *) NULL, (int *) NULL, &myID);
- d141 1
- a141 1
- perror( "Sys_GetMachineInfo");
- @
-
-
- 1.1
- log
- @Initial revision
- @
- text
- @d18 1
- a18 1
- static char rcsid[] = "$Header: fsCmd.c,v 1.7 87/08/22 16:26:08 brent Exp $ SPRITE (Berkeley)";
- d28 3
- d41 2
- d49 4
- d115 3
- d119 61
- @
-